# import pytest
# import smtplib
# import time
# from email.mime.text import MIMEText
# from email.mime.multipart import MIMEMultipart
# from email.mime.base import MIMEBase
# from email import encoders
# from email.header import Header
# import mimetypes
# # def send_email(from_addr,password,to_addr,subject,content,
# #                attachment_files):
# #     msg = MIMEMultipart()
# #     msg['From'] = Header(from_addr)
# #     msg['To'] = Header(to_addr)
# #     msg['Subject'] = Header(subject,'utf-8')
# #     msg.attach(MIMEText(content,'plain'))
# #     for file in attachment_files:
# #         content_type, encoding = mimetypes.guess_type(file)
# #         if content_type is None or encoding is not None:
# #             content_type = 'application/octet-stream'
# #         with open(file, 'rb') as f:
# #             part = MIMEBase(*content_type.split('/'))
# #             part.set_payload(f.read())
# #             encoders.encode_base64(part)
# #             part.add_header('Content-Disposition',f'attachment; filename={file}')
# #             msg.attach(part)
# #     try:
# #         smtp_server = 'smtp.qq.com'
# #         with smtplib.SMTP_SSL(smtp_server,465) as smtpobj:
# #             smtpobj.login(from_addr,password)
# #             smtpobj.sendmail(from_addr,to_addr,msg.as_string())
# #             print('邮件发送失败')
# #     except Exception as e:
# #         print('邮件发送失败',e)
# # if __name__ == '__main__':
# #     pytest.main(["-v","--html=测试报告.html","./"])
# #     time.sleep(10)
# #     from_addr = '2232152882@qq.com'
# #     password = 'sjkoiyckbzyadhgg'
# #     to_addr = '2232152882@qq.com'
# #     subject = 'Python SMTP 邮件测试'
# #     attachment_files = ['测试报告.html']
# #     send_email(from_addr,password,to_addr,subject,'',attachment_files)
# def send_email(from_addr, password, to_addr, subject, content, attachment_files=[]):
#     msg = MIMEMultipart()
#     msg['From'] = Header(from_addr)
#     msg['To'] = Header(to_addr)
#     msg['Subject'] = Header(subject, 'utf-8')
#     msg.attach(MIMEText(content, 'plain'))
#
#     # ... 附件处理代码保持不变 ...
#
#     try:
#         smtp_server = 'smtp.qq.com'
#         # 修正1：使用 SMTP_SSL() 连接465端口
#         with smtplib.SMTP_SSL(smtp_server, 465) as smtpobj:
#             # 修正2（可选但推荐）：显式进行EHLO握手
#             smtpobj.ehlo()
#             smtpobj.login(from_addr, password)
#             smtpobj.sendmail(from_addr, to_addr, msg.as_string())
#             # 修正3：更正成功提示信息
#             print('邮件发送成功！')
#     except Exception as e:
#         print('邮件发送失败', e)
#
# if __name__ == '__main__':
#     pytest.main(["-v", "--html=测试报告.html", "./"])
#     time.sleep(10)
#     from_addr = '2232152882@qq.com'  # 注意：这里去掉了邮箱地址末尾多余的空格
#     password = 'sjkoiyckbzyadhgg'    # 请确认这是QQ邮箱生成的授权码，而非登录密码
#     to_addr = '2022566488@qq.com'
#     subject = 'Python SMTP 邮件测试'
#     attachment_files = ['测试报告.html']
#     send_email(from_addr, password, to_addr, subject, '我要上王者', attachment_files)
import pytest
import os

if __name__ == '__main__':
    # 注意：在列表中增加了 '--alluredir', './json_report' 这一对参数
    pytest.main(['-vs', 'test_Calc.py::TestCalc::test_sub1', '--alluredir', './json_report'])
    os.system('allure generate ./json_report -o ./html_report --clean')